#include<stdio.h>
#include<stdlib.h>

struct PRICE
{
	char name[21];
	int aver_score;
	int class_score;
	char is_cadre;
	char is_west;
	int paper;
	int sum;
};

int main(void)
{
	int n,max=0,sum_all=0;
	scanf("%d",&n);
	struct PRICE stu[n];
	for(int i=0;i<n;i++)
	{
		stu[i].sum=0;
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].aver_score,&stu[i].class_score,&stu[i].is_cadre,&stu[i].is_west,&stu[i].paper);
		if(stu[i].aver_score>80&&stu[i].paper>=1)
		{
			stu[i].sum+=8000;
		}
		if(stu[i].aver_score>85&&stu[i].class_score>80)
		{
			stu[i].sum+=4000;
		}
		if(stu[i].aver_score>90)
		{
			stu[i].sum+=2000;
		}
		if(stu[i].aver_score>85&&stu[i].is_west=='Y')
		{
			stu[i].sum+=1000;
		}
		if(stu[i].class_score>80&&stu[i].is_cadre=='Y')
		{
			stu[i].sum+=850;
		}
		sum_all+=stu[i].sum;
	}
	
	for(int i=1;i<n;i++)
	{
		if(stu[i].sum>stu[max].sum)
		{
			max=i;
		}
	}
	
	printf("%s\n%d\n%d",stu[max].name,stu[max].sum,sum_all);
	
	return 0;
}

